home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
dskut
/
qcmp114.zip
/
QCMP.DOC
< prev
next >
Wrap
Text File
|
1991-01-23
|
13KB
|
317 lines
QCMP 1.14
---------
Purpose
-------
QCMP compares two files, or two groups of files. It is not
designed to isolate file differences, but simply to tell you
whether or not files are identical. This can be used to verify
file-by-file backup operations, for smart batch files, in
Personal REXX programs, etc. QCMP is similar to DOS's COMP
command except that (1) it doesn't display differences; (2) the
display is better suited for automated processing; and (3) it
returns a usable errorlevel.
Version 1.13 adds SHARE support but makes no other changes.
| indicates changes in recent versions.
Usage
-----
Here is the syntax for running QCMP:
qcmp filespec1 filespec2 [-Dn] [-H] [-T]
Usage is largely the same as DOS's COMP command except that
QCMP does not prompt for missing input, and the three option
switches are not found in COMP. The optional switches can be
introduced by either a hypen (-) or a slash (/).
Filespec1 can be any valid file or directory specification:
d: Drive only
path Path only
d:file.ext Drive, filename, extension
path\file.ext Path, filename, extension
d:path\file.ext Drive:path. filename, extension
If no drive is specified, the current drive is assumed. If no
path is specified, the current directory for the selected
drive is assumed.
If no filename is specified, "*.*" (all files) is assumed.
If no extension is specified, "*" is assumed. If you really
want to check a file that has no extension, use a single "."
with no extension. For example, "foo" is assumed to be "foo.*",
but "foo." matches only a file called "foo" (not "foo.txt").
Filespec2 is identical to filespec1 except that a missing
filename will default to the filename used in filespec1 rather
than "*.*".
Examples:
qcmp *.* b:
Compare all files in current directory of current drive
with files of the same name on drive B:
qcmp a: b:
Compare all files on drive A: to same files on drive B:.
qcmp \asm\*.asm b:*.bak
Compare all *.ASM files in \ASM directory of current
drive to files with same root name but .BAK extension on
drive B.
Display levels
--------------
The -D (Display level) switch affects the results messages that
are displayed. Valid display levels are:
-D0 No display; return errorlevel only.
-D1 Display results only for comparison errors
-D2 Display results for all files compared
The -D0 level is intended for batch files and Personal REXX
programs (or other programs that can execute QCMP and examine
the result code). The -D2 level is the default.
Checking the timestamp
----------------------
If two files have identical contents, QCMP will normally
consider them to be the same even if their dates or times
differ. However, if you use the -T switch, QCMP will also
compare the files' modification dates and times; if they are
different, the files are reported as being different, even if
their contents are the same.
Including hidden files
----------------------
If you want to include hidden files such as IBMBIO.COM in your
comparisons, add the -H switch. For example,
qcmp -h c:\*.* b:
would compare all of the files in the root directory of drive C
with copies on drive B, including hidden files (possibly,
IBMBIO.COM and IBMSYS.COM). Without the -H, hidden files would
not be included.
Results (display)
-----------------
For each matching file, QCMP will display the following line:
filespec1 - filespec2 > result
where FILESPEC1 and FILESPEC2 are the two files currently being
compared, and RESULT is the comparison result. RESULT is one of
the following:
OK Files are identical
ERROR Files are same size but not identical
SIZE DIFF Files are different sizes
READ ERROR Error reading one of the files.
DATE/TIME DIFF Files' timestamps are different (this
error reported only if -T selected)
<file> NOT FOUND Named file not found
Note that the -D1 display level suppresses the display of files
for which the result is "OK".
Results (errorlevel)
--------------------
QCMP returns an errorlevel to DOS that describes the comparison
results. Errorlevel are as follows:
0 All files are identical (all "OK")
1 At least one comparison failed
254 No files found matching first filespec
255 Usage error, disk error, or insufficient memory
Note that if you specify the -d0 display level, ONLY the error
level is returned; there is no display at all. When -d0 is
specified, QCMP will terminate as soon as an errorlevel is
determined; for example, it will not bother to continue
comparing more files after one comparison fails, because the
errorlevel must be 1 regardless of the results of subsequent
comparisons.
Sample use: batch files
-----------------------
1. Branch to BACKUP if any *.ASM file in current drive is not
preperly backed up to B:*.BAK, else continue.
qcmp -d0 *.asm b:*.bak
If errorlevel 255 goto QCERR
If errorlevel 254 goto NOFILES
If errorlevel 1 goto BACKUP
... (all files OK)
...
:BACKUP
... (needs backup)
...
:NOFILES
... (no files match filespec1)
:QCERR
... (error in qcmp, or no matching files)
...
2. Back up any file in current directory that needs backup to
drive B. This requires two batch files, one called by the other
using the technique of executing another copy of COMMAND.COM
with the second batch file as a parameter.
BAK.BAT:
FOR %%a IN (*.*) DO command /c xxbak %%a
XXBAK.BAT:
qcmp -d0 %1 b:
IF NOT errorlevel 1 GOTO OK
echo Backing up %1
copy %1 b:
GOTO exit
:OK
echo %1 is backed up
:EXIT
Sample use: Personal REXX
-------------------------
1. Determine whether all files in current directory were
backed up successfully to drive b:
'qcmp -d0 *.* b:'
If rc = 0 Then
Say 'All files backed up OK'
Else If rc = 1 Then
Say 'Error in backup!'
Else If rc = 254 Then
Say 'No Matching files'
Else If rc = 255 Then
Say 'qcmp error!'
2. Create a list of files that need to be backed up from the
current directory of drive C to drive B, and back them all up.
The sample code assumes that STACKDRV and STACKMGR are
installed; without the STK device, the same could be accomplised
by redirecting output to a temporary file, reading the file line
by line, and then deleting the file.
'qcmp c: b: > stk'
If rc > 1 Then Do